﻿<Window x:Class="Notoric.Gui.Windows.NewScoreDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:rb="clr-namespace:Fluent;assembly=Fluent"
        xmlns:ls="clr-namespace:LukasKopenec.LocalizationSupport;assembly=LocalizationSupport"
        xmlns:vm="clr-namespace:Notoric.ViewModel;assembly=ViewModel"
        xmlns:vme="clr-namespace:Notoric.ViewModel.Elements;assembly=ViewModel"
        xmlns:my="clr-namespace:Notoric.Gui.Windows"
        xmlns:cvr="clr-namespace:Notoric.ViewModel.Converters;assembly=ViewModel"
        Title="Edit Score Properties" Height="500" Width="564" Background="#FFF0F0F0" 
        ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded">
    <Window.Resources>
        <cvr:LengthConverter x:Key="lengthConverter" SwitchConversionDirection="True"/>
    </Window.Resources>
    <StackPanel Orientation="Vertical" Margin="7 7 7 7">
        <StackPanel Height="420" Background="White" x:Name="PART_FirstPage">
            <GroupBox x:Name="PART_CreationMode" Header="Creation Mode">
                <StackPanel Orientation="Vertical" Margin="0 2 0 2">
                    <RadioButton x:Name="PART_BlankScore" Content="Create Blank Score" GroupName="CreationMode" 
                                 IsChecked="True" Checked="RadioButton_Checked" 
                                 IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:NewScoreDialog, AncestorLevel=1}, Path=IsNewScore}" />
                    <RadioButton x:Name="PART_Generate" Content="Genereate From Composition(s)" GroupName="CreationMode"
                                 Checked="RadioButton_Checked"
                                 IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:NewScoreDialog, AncestorLevel=1}, Path=IsNewScore}"/>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="Page Format">
                <StackPanel Orientation="Vertical">
                    <rb:Spinner x:Name="PART_Width" Format="0.00 cm" Maximum="50" Minimum="0.25" Text="{ls:Localize Windows.PageAppearanceDialog.Width}" 
                            Value="{Binding DefaultPageWidth,Converter={StaticResource lengthConverter},Mode=TwoWay}"/>
                    <rb:Spinner x:Name="PART_Height" Grid.Row="1" Grid.Column="1" Format="0.00 cm" Maximum="50" Minimum="0.25" Text="{ls:Localize Windows.PageAppearanceDialog.Height}"
                            Value="{Binding DefaultPageHeight,Converter={StaticResource lengthConverter},Mode=TwoWay}"/>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="Metadata">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition Height="60"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="72"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" Content="Title:"/>
                    <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Title, Mode=TwoWay}"/>
                    
                    <Label Grid.Column="0" Grid.Row="1" Content="Subtitle:" />
                    <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding SubTitle, Mode=TwoWay}"/>
                    
                    <Label Grid.Column="0" Grid.Row="2" Content="Subject:"/>
                    <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Subject, Mode=TwoWay}"/>
                    
                    <Label Grid.Column="0" Grid.Row="3" Content="Description:"/>
                    <TextBox Grid.Column="1" Grid.Row="3" Height="64" TextWrapping="Wrap" 
                             VerticalScrollBarVisibility="Visible" Text="{Binding Description, Mode=TwoWay}"/>
                    
                    <Grid Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="72"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="72"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        
                        <Label Grid.Column="0" Grid.Row="0" Content="Language:"/>
                        <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Language, Mode=TwoWay}"/>

                        <Label Grid.Column="2" Grid.Row="0" Content="Identifier:"/>
                        <TextBox Grid.Column="3" Grid.Row="0" Text="{Binding Identifier, Mode=TwoWay}"/>

                        <Label Grid.Column="0" Grid.Row="1" Content="Date:"/>
                        <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Date, Mode=TwoWay}"/>
                        
                        <Label Grid.Column="0" Grid.Row="2" Content="Rights:"/>
                        <TextBox Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="3" Text="{Binding Rights, Mode=TwoWay}"/>
                        
                        <Label Grid.Column="0" Grid.Row="3" Content="Publisher:"/>
                        <TextBox Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="3" Text="{Binding Publisher, Mode=TwoWay}"/>
                        
                    </Grid>
                </Grid>
            </GroupBox>
        </StackPanel>
        <Grid Visibility="Collapsed" Height="420" Background="White" x:Name="PART_SecondPage">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="120"/>
                <RowDefinition Height="90"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="180"/>
                <ColumnDefinition Width="42"/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            
            <TreeView x:Name="PART_Compositions" Width="180" Grid.RowSpan="2"
                      ItemsSource="{Binding Mode=OneWay, Path=Compositions.Children, RelativeSource={RelativeSource FindAncestor, AncestorType=my:NewScoreDialog, AncestorLevel=1}}"
                      VerticalAlignment="Stretch"
                      SelectedItemChanged="PART_Compositions_SelectedItemChanged" Margin="0"
                      MouseDoubleClick="PART_Compositions_MouseDoubleClick">
                <TreeView.Resources>
                    <DataTemplate DataType="{x:Type vme:Composition}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding Path=Icon, Mode=OneWay}" Height="16" Width="16" Margin="0 0 4 0"/>
                            <TextBlock Text="{Binding Path=DisplayName, Mode=OneWay}"/>
                        </StackPanel>
                    </DataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type vm:Directory}"  ItemsSource="{Binding Path=Children, Mode=OneWay}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding Path=Icon, Mode=OneWay}" Height="16" Width="16" Margin="0 0 4 0"/>
                            <TextBlock Text="{Binding Path=DisplayName, Mode=OneWay}"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.Resources>
            </TreeView>
                            
            <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Margin="7 10 10 7">
                <Button Height="32" HorizontalAlignment="Stretch" ToolTip="Add Composition"
                        x:Name="PART_AddComposition" IsEnabled="False" Click="PART_AddComposition_Click">
                    <Button.Content>
                        <Image Source="../Resources/Images/Windows/RightArrow.png" Height="16" Width="16"/>
                    </Button.Content>
                </Button>
                <Button Height="32" HorizontalAlignment="Stretch" Margin="0 10 0 0"
                        ToolTip="Remove Composition" IsEnabled="False" x:Name="PART_RemoveComposition" Click="PART_RemoveComposition_Click">
                    <Button.Content>
                        <Image Source="../Resources/Images/Windows/LeftArrow.png" Height="16" Width="16"/>
                    </Button.Content>
                </Button>
                <Button Height="32" HorizontalAlignment="Stretch" Margin="0 10 0 0"
                        ToolTip="Move Up" IsEnabled="False" x:Name="PART_MoveCompositionUp" Click="PART_MoveCompositionUp_Click">
                    <Button.Content>
                        <Image Source="../Resources/Images/Windows/UpArrow.png" Height="16" Width="16"/>
                    </Button.Content>
                </Button>
                <Button Height="32" HorizontalAlignment="Stretch" Margin="0 10 0 0"
                        ToolTip="Move Down" IsEnabled="False" x:Name="PART_MoveCompositionDown" Click="PART_MoveCompositionDown_Click">
                    <Button.Content>
                        <Image Source="../Resources/Images/Windows/DownArrow.png" Height="16" Width="16"/>
                    </Button.Content>
                </Button>
            </StackPanel>
            
            <ListBox x:Name="PART_SelectedCompositions" Grid.Column="2" Grid.Row="0" 
                        ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:NewScoreDialog, AncestorLevel=1}, Path=PresentedCompositions, Mode=OneWay}"
                        SelectionChanged="PART_SelectedCompositions_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type my:CompositionInfo}">
                        <TextBlock Text="{Binding Composition.DisplayName, Mode=OneWay}"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            
            <ListBox x:Name="PART_PresentedParts" Margin="7 0 0 0" Grid.Row="0" Grid.Column="3" 
                        ItemsSource="{Binding ElementName=PART_SelectedCompositions, Path=SelectedItem.Composition.Parts, Mode=OneWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type vme:PartDescriptor}">
                        <StackPanel Orientation="Horizontal">
                            <CheckBox IsChecked="True" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" />
                            <TextBlock Text="{Binding Name, Mode=OneWay}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            
            <StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" Margin="7">
                <rb:Spinner x:Name="PART_FirstMeasure" Text="First Measure:" Format="0" Minimum="1" 
                            Maximum="{Binding ElementName=PART_SelectedCompositions, Path=SelectedItem.Composition.MeasuresCount, Mode=OneWay}"
                            IsEnabled="False"
                            ValueChanged="PART_FirstMeasure_ValueChanged"/>
                <rb:Spinner x:Name="PART_LastMeasure" Text="Last Measure:" Format="0" 
                            Minimum="{Binding ElementName=PART_FirstMeasure, Path=Value, Mode=OneWay}" 
                            Maximum="{Binding ElementName=PART_SelectedCompositions, Path=SelectedItem.Composition.MeasuresCount, Mode=OneWay}"
                            IsEnabled="False"
                            ValueChanged="PART_LastMeasure_ValueChanged"/>
                <rb:Spinner x:Name="PART_MeasuresPerSystem" Text="Measures Per System:" Format="0" Minimum="1" 
                            Maximum="{Binding ElementName=PART_SelectedCompositions, Path=SelectedItem.Composition.MeasuresCount, Mode=OneWay}"
                            IsEnabled="False"
                            ValueChanged="PART_MeasuresPerSystem_ValueChanged"/>
                <rb:Spinner x:Name="PART_SystemsPerPage" Text="Systems Per Page:" Format="0" Minimum="1" 
                            Maximum="32767"
                            IsEnabled="False"
                            ValueChanged="PART_SystemsPerPage_ValueChanged"/>
            </StackPanel>
            
            <TextBlock Grid.Column="0" Grid.Row="3" VerticalAlignment="Bottom" Grid.ColumnSpan="4" Margin="7"
                        Text="Select the compositions that you want to include in your score and order them. You may include one composition more than once if you need. Then select the parts and measures that you want to present and edit the number of measures &amp; systems that should appear on one page. When you are done, press Finish." TextWrapping="Wrap" />
        </Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="4 4 4 4">
            <Button x:Name="PART_Cancel" Width="64" Height="24" Margin="0 0 4 0"
                    Content="Cancel" Click="PART_Cancel_Click" IsCancel="True"/>
            <Button x:Name="PART_Previous" Width="64" Height="24" Margin="0 0 4 0"
                    Content="&lt; Previous" IsEnabled="False" Click="PART_Previous_Click"/>
            <Button x:Name="PART_Next" Height="24" Width="64" Margin="0 0 4 0" Content="Next >" IsEnabled="False"
                    Click="PART_Next_Click"/>
            <Button x:Name="PART_Finish" Height="24" Width="64" Margin="0 0 4 0" Content="Finish"
                    Click="PART_Finish_Click" IsDefault="True"/>
        </StackPanel>
    </StackPanel>
</Window>
